﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp.Delegate
{
    public class SystemDelegateScenario
    {
        public static void Invoke()
        {
            Func<string> func = new Func<string>(GetMessage);
            Func<string, string> func2 = new Func<string, string>(GetMessage);





            var msg1 = func();
            var msg2 = func2("func delegate test");

            Console.WriteLine(msg1);
            Console.WriteLine(msg2);


            Action<string> action = new Action<string>(ShowLog);

            action("action test");
        }


        public static void ShowLog(string msg)
        {
            Console.WriteLine("action delegate test message:{0} ", msg);
        }


        public static string GetMessage()
        {
            return "this is a message";
        }

        public static string GetMessage(string msg)
        {
            return string.Format("message is {0}", msg);
        }
    }
}
